package com.liang.frpdemo;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Func1;

public class NewLocationHelper {

	private NewApiWrapper api;
	private static NewLocationHelper helper = new NewLocationHelper();

	private NewLocationHelper() {
		api = new NewApiWrapper();
	}
	
	public static NewLocationHelper getHelper(){
		return helper;
	}

	Observable<Void> commit(final String address){
		Observable<LocationBean> locationJob = api.getLocation(address);
		Observable<Void> submitJob = locationJob.flatMap(new Func1<LocationBean, Observable<Void>>() {
			@Override
			public Observable<Void> call(LocationBean locationBean) {
				return api.submitLocation(locationBean);
			}
		});
		return submitJob;
	}

}
